package com.zc.designmodel.structural.criteria;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: zhuCan
 * @date: 2020/4/12 18:07
 * @description:
 */
public class Test {

  public static void main(String[] args) {
    List<Person> persons = new ArrayList<Person>();

    persons.add(new Person("Robert","Male", "Single"));
    persons.add(new Person("John","Male", "Married"));
    persons.add(new Person("zhuc","Female", "Married"));
    persons.add(new Person("zhucan","Female", "Single"));
    persons.add(new Person("Mike","Male", "Single"));
    persons.add(new Person("zhu123","Male", "Single"));

    Criteria male = new CriteriaMale();
    Criteria female = new CriteriaFamilyName();
    Criteria single = new CriteriaSingleDog();
    Criteria singleMale = new AndCriteria(single, male);
    Criteria singleOrFemale = new OrCriteria(single, female);

    System.out.println("Males: ");
    printPersons(male.meetCriteria(persons));

    System.out.println("\nFemales: ");
    printPersons(female.meetCriteria(persons));

    System.out.println("\nSingle Males: ");
    printPersons(singleMale.meetCriteria(persons));

    System.out.println("\nSingle Or Females: ");
    printPersons(singleOrFemale.meetCriteria(persons));
  }

  public static void printPersons(List<Person> persons){
    for (Person person : persons) {
      System.out.println("Person : [ Name : " + person.getName()
          +", Gender : " + person.getGender()
          +", Marital Status : " + person.getMaritalStatus()
          +" ]");
    }
  }
}

